"use strict";
const express = require('express');
const logger = require('../conf/logger');
const router = express.Router();
const request = require('request-promise');


/* GET home page. */
router.get('/', async function(req, res, next) {
	let data = await request({
		url :'http://xiaoliao.vipappsina.com/index.php/Api386/index/pad/0/sw/0/cid/joke/p/1/markId/0/date/',
		json:true
	});

	let title =  data.rows[0].title;

	let dingRes = await request({
		url:'https://oapi.dingtalk.com/robot/send?access_token=5c6e881fd258069e0a52e6bfa8e81bf5d2cbbcb106b3fabdf42e0256ba5aeeff',
		method:'POST',
        body:{
            msgtype: "text",
            text: {
                content: "赶紧上报数据，别忘了 @15188386136 顺便骂一下雪芬 \n"+title
            },
            at: {
                atMobiles: [
                    "15188386136"
                ],
                isAtAll: false
            }
        },
        json:true
	})

	res.json(dingRes);
})


module.exports = router;
